<template>
  <div class="delivery-append-confirm-modal">
    <modal-temp ref="modal" @confirm="confirm()" modal-name="确认新增送货单">
      <template #btn>
        <a-button size="large" type="primary" class="btn" @click="appendDelivery">
          确认
        </a-button>
      </template>
      <template #content>
        <p>确认新增送货单</p>
        <div class="delivery-append-confirm-modal-inf">
          <p>客户Id：{{clientId}}</p>
          <p>客户名称：{{name}}</p>
          <p>送货单总金额：{{totalAmount}}</p>
          <p>送货单订单量：{{orderQuantity}}</p>
          <small>加入送货单中的订单 将不被允许修改。如要修改，需删除送货单。</small>
        </div>
      </template>
    </modal-temp>
  </div>
</template>

<script>
import ModalTemp from './ModalTemp';
import {
  divide3Float3Fixed
} from '@/utils/NumberChange.js';

export default {
  name: "DeliveryAppendConfirmModal",
  props: {
    summary: Object
  },
  data() {
    return {
    };
  },
  computed: {
    clientId() {
      return this.summary.clientId ?? 'Error';
    },
    name() {
      return this.summary.name ?? 'Error';
    },
    totalAmount() {
      // 由于传输过来的数据是乘了1000倍的，因此要将它除回去才能展现正确的数据
      const totalAmount = this.summary.totalAmount ?? 'Error';
      return divide3Float3Fixed(totalAmount);
    },
    orderQuantity() {
      return this.summary.orderQuantity ?? 'Error';
    }
  },
  mounted() {

  },
  watch: {

  },
  methods: {
    confirm() {
      if (this.orderQuantity > 0) {
        this.$emit('confirm');
      }
      else {
        this.$notification['warning']({
          message: '新增送货单',
          description:
            `你没有选择任何1张有效的订单。`,
        });
      }
    },
    appendDelivery() {
      this.$emit('appendDelivery');
    }
  },
  components: {
    ModalTemp,
  },
};
</script>

<style scoped lang="scss">
.delivery-append-confirm-modal {
  .inf {
    margin-left: 20px;
  }
}
</style>

<style lang="scss">
.delivery-append-confirm-modal-inf {
  margin-left: 20px;
  >small {
    color: darkcyan;
  }
}
</style>
